<?php
/*
 * Created on 31.01.2006
 *
 */

class conf_filterHandler
{

    var $keep;

    function startElement (& $sender, $attrs, $line)
    {
        if (empty($attrs['class']) && empty($attrs['keep']) && empty($attrs['restore']))
            die ("Attribute class missing in tag filter in line $line\n");
        if (empty($attrs['match']) && empty($attrs['keep']) && empty($attrs['restore']))
            die ("Attribute match missing in tag filter in line $line\n");
        if (!empty($attrs['restore']))
            $sender->appendCode('$filter = '.$attrs['restore'].';'."\n");
        if (!empty($attrs['class']))
            $sender->appendCode('$filter[0]["class"] = '.$attrs['class'].';'."\n");
        if (!empty($attrs['match']))
            $sender->appendCode('$filter[0]["match"] = '.$attrs['match'].';'."\n");
        if (!empty($attrs['group']))
            $sender->appendCode('$filter[0]["group"] = '.$attrs['group'].';'."\n");
        if (!empty($attrs['capture']))
            $sender->appendCode('$filter[0]["capture"] = '.$attrs['capture'].';'."\n");
        if (!empty($attrs['captureAttribute']))
            $sender->appendCode('$filter[0]["captureAttribute"] = '.$attrs['captureAttribute'].';'."\n");
        if (!empty($attrs['keep']))
            $sender->appendCode('$actionform->set('.$attrs['keep'].', $filter);'."\n");
        if (!empty($attrs['keep']))
            $this->keep = $attrs['keep'];
    }
    
    function endElement (& $sender)
    {
        if (!empty($this->keep))
            $sender->appendCode('$actionform->set('.$this->keep.', $filter);'."\n");
        $sender->appendCode('$filterchain->addFilter($filter); unset($filter);'."\n");
    }

} 


?>
